<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../common/top.jsp"%>
<script src="js/TotalCalculate.js"></script>
<div id="BackLink">
    <a href="mainView">Return to Main Menu</a>
</div>

<div class="c">

    <div class="common">
        <div class="title">
            Shopping Cart
        </div>
        <form id="form" action="updateCart" method="post">
            <div class="table-content">
                <table id="autoUpdate">
                    <tr class="head">
                        <th>Item ID</th>
                        <th>Product ID</th>
                        <th>Description</th>
                        <th>In Stock?</th>
                        <th>Quantity</th>
                        <th>List Price</th>
                        <th>Total Cost</th>
                        <th>&nbsp;</th>
                    </tr>

                    <c:if test="${sessionScope.cart.numberOfItems == 0}">
                        <tr>
                            <td colspan="8"><b>Your cart is empty.</b></td>
                        </tr>
                    </c:if>
                    <c:forEach var="cartItem" items="${sessionScope.cart.cartItems}">
                        <tr>
                            <td>
                                <a href="itemView?itemId=${cartItem.item.itemId}">${cartItem.item.itemId}</a>
                            </td>
                            <td>${cartItem.item.product.productId}</td>
                            <td>${cartItem.item.attribute1} ${cartItem.item.attribute2}
                                    ${cartItem.item.attribute3} ${cartItem.item.attribute4}
                                    ${cartItem.item.attribute5} ${cartItem.item.product.name}</td>
                            <td>${cartItem.inStock}</td>
                            <td>
                                <input type="text" class="productCount" name="${cartItem.item.itemId}" value="${cartItem.quantity}">
                            </td>
                            <td class="Price"><fmt:formatNumber value="${cartItem.item.listPrice}"
                                                  pattern="$#,##0.00" /></td>
                            <td class="Total"><fmt:formatNumber value="${cartItem.total}"
                                                  pattern="$#,##0.00" /></td>
                            <td>
                                <a href="removeCartItem?workingItemId=${cartItem.item.itemId}" class="Button">Remove</a>
                            </td>
                        </tr>
                    </c:forEach>

                    <tr>
                        <td colspan="7">
                            Sub Total: <fmt:formatNumber value="${sessionScope.cart.subTotal}" pattern="$#,##0.00"/>
                            <input type="submit" style="background-color: #90b4d6;color: white;border: none;" value="Update Cart">
                        </td>
                        <td>&nbsp;</td>
                    </tr>
                </table>
            </div>
        </form>

        <c:if test="${sessionScope.cart.numberOfItems > 0}">
            <a href="newOrderView" class="Button">Proceed to Checkout</a>
        </c:if>
    </div>
</div>
<div id="MyList">
    <c:if test="${sessionScope.loginAccount != null}">
        <c:if test="${!empty sessionScope.loginAccount.listOption}">
            <%@ include file="includeMyList.jsp"%>
        </c:if>
    </c:if>
</div>

<div id="Separator">&nbsp;</div>


<%@ include file="../common/bottom.jsp"%>